<template>
  <u-count-down :timestamp="cut_time"></u-count-down>
</template>

<script>
  export default {
    data() {
      return {
        cut_time: '', // 剩余时间
        end_time: '',
      }
    },
    props: {
      time: {
        type: String,
        default: '',
      },
    },
    watch: {
      time: {
        handler(val) {
          console.log(val)
          this.end_time = +val
          val && this.seckillTime()
        },
        immediate: true,
      },
    },
    methods: {
      seckillTime() {
        let that = this
        let now_time = (new Date().getTime() / 1000).toFixed(0) // 当前时间
        // 剩余时间
        let cut_time = +this.end_time - +now_time
        console.log(cut_time)
        this.cut_time = cut_time
      },
    },
  }
</script>

<style></style>
